<%@ page pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='ttblsjxt'/></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
    <style>
        html {
            background: #fff;
        }
    </style>
</head>

<body>
<div class="layui-container">
    <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">

        <form:form commandName="gift" method="${_method }" class="layui-form" id="form">
            <input type="hidden" name="_method" value="${_method }"/>
            <form:hidden path="id"/>

            <div class="layui-form-item feijin-validityType-gudin-area">
                <label class="layui-form-label"> <fmt:message key='zphdmc'/></label>
                <div class="layui-form-mid layui-word-aux">
                        ${gift.name}
                </div>
            </div>

            <div class="layui-form-item feijin-zenpin-area">
                <label class="layui-form-label"><fmt:message key='zp'/></label>
                <div class="layui-form-mid layui-word-aux">
                    <table class="layui-table" lay-size="sm" id="feijin-sku-table">
                        <thead>
                        <tr>
                            <th><fmt:message key='spbh'/></th>
                            <th><fmt:message key='spmc'/></th>
                            <th><fmt:message key='sptp'/></th>
                        </tr>
                        </thead>
                        <tbody>


                        <c:forEach items="${giftGoodses}" var="giftGoods">

                            <tr>
                                <td>${giftGoods.goods.goodsNo}</td>
                                <td>${giftGoods.goods.name}</td>
                                <td><img class="preview" style="width:40px;height:40px;" src="${store_domain}/uploads/${giftGoods.goods.defaultImage}"/></td>
                            </tr>

                        </c:forEach>
                        </tbody>

                    </table>

                </div>
            </div>


            <div class="layui-form-item feijin-validityType-gudin-area">
                <label class="layui-form-label"> <fmt:message key='zpyxq'/></label>
                <div class="layui-form-mid layui-word-aux">
                        ${gift.beginDateOfValidity} - ${gift.endDateOfValidity}
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"> <fmt:message key='mkje'/></label>
                <div class="layui-form-mid layui-word-aux">
                        ${gift.standardsAmount}
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"> <fmt:message key='sysplx'/></label>
                <div class="layui-form-mid layui-word-aux">
                    <c:choose>
                        <c:when test="${gift.scopeGoodsType eq 1}"><fmt:message key='sysp1'/></c:when>
                        <c:when test="${gift.scopeGoodsType eq 2}"><fmt:message key='zdsp'/></c:when>
                        <c:when test="${gift.scopeGoodsType eq 3}"><fmt:message key='zdfl'/></c:when>
                    </c:choose>
                </div>
            </div>

            <c:if test="${gift.scopeGoodsType eq 2}">

                <div class="layui-form-item" id="feijin-scopeGoods">
                    <label for="" class="layui-form-label"> <fmt:message key='sysp'/></label>
                    <div class="layui-form-mid layui-word-aux">
                        <table class="layui-table" lay-size="sm">
                            <thead>
                            <th><fmt:message key='spbh'/></th>
                            <th><fmt:message key='spmc'/></th>
                            <th><fmt:message key='sptp'/></th>
                            </thead>
                            <tbody id="feijin-chooseGoods-table">
                            <c:forEach items="${scopes}" var="item">

                                <tr data-id='${item.goods.id}' class='feijin-scopeGoods-ids'>
                                    <td>${item.goods.goodsNo}</td>
                                    <td>${item.goods.name }</td>
                                    <td><img style='width:30px;' src='${store_domain}/uploads/${item.goods.defaultImage}'/></td>
                                </tr>

                            </c:forEach>

                            </tbody>

                        </table>

                    </div>
                </div>
            </c:if>

            <c:if test="${gift.scopeGoodsType eq 3}">
                <div class="layui-form-item" id="feijin-channels">
                    <label class="layui-form-label"> <fmt:message key='splm'/></label>
                    <div class="layui-form-mid layui-word-aux">

                        <c:forEach items="${channels}" var="channel">
                            ${channel.channel.name}
                        </c:forEach>
                    </div>

                </div>
            </c:if>


            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend><fmt:message key='shxx'/></legend>
            </fieldset>

            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='shzt'/></label>
                <div class="layui-form-mid layui-word-aux">
                    <c:choose>
                        <c:when test="${gift.status eq 1}"><fmt:message key='ysj'/></c:when>
                        <c:when test="${gift.status eq 2}"><fmt:message key='xj'/></c:when>
                        <c:when test="${gift.status eq 3}"><fmt:message key='dsh'/></c:when>
                        <c:when test="${gift.status eq 4}"><fmt:message key='shtg'/></c:when>
                        <c:when test="${gift.status eq 5}"><fmt:message key='shbtg'/></c:when>
                    </c:choose>
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label"><b style="color:red">*</b> <fmt:message key='shjg'/></label>
                <div class="layui-input-inline" style="width:70%;">
                    <input type="radio" name="status" lay-filter="status" lay-verify="required" value="4" title="<fmt:message key='shtg'/>" <c:if test="${gift.status eq 4}">checked="checked"</c:if>/>
                    <input type="radio" name="status" lay-filter="status" lay-verify="required" value="5" title="<fmt:message key='shbtg'/>" <c:if test="${gift.status eq 5}">checked="checked"</c:if>/>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='shbz'/></label>
                <div class="layui-input-inline" style="width:80%;">
                    <form:textarea path="note" class="layui-textarea" style="height:100px;width:100%"/>
                </div>
            </div>


            <div class="layui-input-block">
                <div style="display: none">
                    <input type="button" value="<fmt:message key='bc'/>" class="layui-btn" id="submit" lay-filter="submit" lay-submit>
                </div>
            </div>


        </form:form>
    </div>
</div>
<script>
    $(function () {

        $("#submit").click(function () {

            var status = $("input[name='status']:checked").val();
            if (!status) {

                layer.msg("<fmt:message key='qxzshjg'/>");
                return false;

            }

            $("#form").ajaxSubmit({
                success: function (result) {
                    if (result.status) {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        parent.$("#search").click();
                    } else {
                        layui.use('layer', function () {
                            layer.msg(result.message);
                        });
                    }
                }
            });

        });


    });
</script>
</body>
</fmt:bundle>
</html>